feat: migrate BUI + root tests from Jest to Vitest (follow-up to FR-2609)#6875
Merged
graphite-app[bot] merged 1 commit intomainfrom Apr 30, 2026
Conversation
This was referenced Apr 22, 2026
Contributor
Author
3 tasks
This was referenced Apr 22, 2026
Merged
Contributor
Coverage report for
|
This was referenced Apr 27, 2026
21142d6 to
f2d5ec5
Compare
ace1b59 to
818d02a
Compare
This was referenced Apr 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR completes the Jest → Vitest migration for the remaining test suites in the monorepo (repo-root /src + /scripts, and packages/backend.ai-ui/), aligning them with the existing react/ Vitest setup from FR-2609.
Changes:
- Add new Vitest configs + Jest-compat shims for repo-root and
packages/backend.ai-ui/. - Update tests to use Vitest-compatible mocking (
vi.mock, asyncimportOriginal) and refresh snapshots. - Remove leftover Jest config/deps, and skip known flaky tests with
TODO(FR-2609)markers.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Adds minimal Node-environment Vitest config for root /src and /scripts suites. |
| test/vitest.jest-compat.ts | Adds root Jest→Vitest global shim (globalThis.jest = vi). |
| package.json | Switches root test script from Jest to vitest run and removes embedded Jest config. |
| scripts/i18n-merge-driver.test.ts | Updates mocking to vi.mock and skips a CJS-mock-incompatible test. |
| react/package.json | Removes Jest-related devDependencies from the React workspace. |
| react/jest.config.cjs | Deletes React Jest config file. |
| packages/backend.ai-ui/vitest.config.ts | Adds BUI Vitest config mirroring React’s transform pipeline + Relay/SVGR support. |
| packages/backend.ai-ui/package.json | Switches BUI tests from Jest to Vitest and updates devDependencies. |
| packages/backend.ai-ui/test/vitest.jest-compat.ts | Adds BUI Jest→Vitest global shim (globalThis.jest = vi). |
| packages/backend.ai-ui/test/jest-globals-shim.ts | Adds @jest/globals specifier shim to re-export from Vitest. |
| packages/backend.ai-ui/src/components/fragments/BAIDomainSelect.test.tsx | Migrates jest.mock → vi.mock. |
| packages/backend.ai-ui/src/components/BAIStatistic.test.tsx | Migrates jest.mock → vi.mock. |
| packages/backend.ai-ui/src/components/BAIBulkEditFormItem.test.tsx | Migrates jest.mock → vi.mock. |
| packages/backend.ai-ui/src/components/BAIBackButton.test.tsx | Replaces jest.requireActual with Vitest async importOriginal pattern. |
| packages/backend.ai-ui/src/components/BAIFlex.test.tsx | Updates mocks for Vitest compatibility. |
| packages/backend.ai-ui/src/components/snapshots/BAIFlex.test.tsx.snap | Updates snapshot format/header to Vitest output. |
| packages/backend.ai-ui/src/components/BAIButton.test.tsx | Skips flaky motion-related tests under jsdom 29 with TODO markers. |
| packages/backend.ai-ui/src/components/BAIUnmountAfterClose.test.tsx | Skips flaky motion-related tests under jsdom 29 with TODO markers. |
Comments suppressed due to low confidence (1)
scripts/i18n-merge-driver.test.ts:11
process.exitis being overwritten at module scope and never restored. That mutation can leak into other tests in the same Vitest worker and hide real failures (or break code that relies on the real exit behavior). Capture the originalprocess.exitand restore it inafterEach/afterAll(and consider usingvi.spyOn(process, 'exit')instead of direct assignment).
// Mock process.exit to avoid test termination
const mockExit = jest.fn();
process.exit = mockExit as any;
818d02a to
6c1b86d
Compare
f2d5ec5 to
3b0c2a9
Compare
6c1b86d to
7f03080
Compare
411037f to
c25e4c7
Compare
7f03080 to
027a403
Compare
c25e4c7 to
fd46dfb
Compare
1f59ad5 to
d578ec5
Compare
fd46dfb to
593ff3b
Compare
593ff3b to
374a63e
Compare
d578ec5 to
5fc6577
Compare
This was referenced Apr 30, 2026
Merge activity
|
) (#6875) Follow-up to FR-2609. Extends the Vitest cutover to the two remaining Jest suites. No Jira ticket was created for this slice — scope is purely "finish the migration consistently across workspaces". If a Jira issue is needed for tracking, I'll link it after the fact. ## Summary ### `packages/backend.ai-ui/` (14 files, 315 passing + 5 skipped) - New `packages/backend.ai-ui/vitest.config.ts` — mirrors `react/vitest.config.ts` plus `vite-plugin-relay-lite` (matches BUI's existing prod build pipeline). - New `__test__/vitest.jest-compat.ts` (same pattern) + `__test__/jest-globals-shim.ts` that redirects `import { ... } from '@jest/globals'` to a re-export from `vitest`. - Migrated `jest.mock(...)` → `vi.mock(...)` in 4 files (only `vi.mock` is hoisted by Vitest). - `BAIBackButton.test.tsx`: converted `jest.requireActual(...)` to the async `importOriginal` factory pattern. - 4 rc-motion / jsdom-29 flaky tests skipped with `// TODO(FR-2609)` markers. ### Root `/src` + `/scripts` (4 files, 90 passing + 1 skipped) - New `/vitest.config.ts` (Node env, minimal) + `/__test__/vitest.jest-compat.ts`. - Removed the Jest config block from root `package.json`; `test` script now runs `vitest run`. - `scripts/i18n-merge-driver.test.ts`: `jest.mock` → `vi.mock`. The single `fs`-mock test is skipped with `// TODO(FR-2609)` — CJS `require("fs")` inside the plain `.js` driver doesn't pick up Vitest's mock. ### Skip decisions (each with `TODO(FR-2609)` in source) | File | Why skipped | |---|---| | 4 tests in BUI (`BAIButton`, `BAIUnmountAfterClose`) | rc-motion's `supportTransition` stays `true` under jsdom 29, waits for `transitionend` that never fires. Jest's older jsdom triggered the sync fallback. | | 1 test in `i18n-merge-driver.test.ts` | `vi.mock('fs', ...)` doesn't propagate into the CJS `require("fs")` inside the JS driver. | ## Test plan - [x] `pnpm --prefix ./packages/backend.ai-ui run vitest` → 315 pass, 5 skip - [x] `pnpm exec vitest run` (root) → 90 pass, 1 skip - [x] `react/` (FR-2609) remains 856/856 ## Stack Builds on FR-2609. Followed by FR-2611 which retires the CRA/Craco build system now that all test suites are off Jest.
374a63e to
40cf0a8
Compare
5fc6577 to
b598d84
Compare
Base automatically changed from
04-21-feat_fr-2609_vitest_migration_for_react__96.9_pass_rate_822_848_tests_
to
main
April 30, 2026 12:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Follow-up to FR-2609. Extends the Vitest cutover to the two remaining Jest suites. No Jira ticket was created for this slice — scope is purely "finish the migration consistently across workspaces". If a Jira issue is needed for tracking, I'll link it after the fact.
Summary
packages/backend.ai-ui/(14 files, 315 passing + 5 skipped)packages/backend.ai-ui/vitest.config.ts— mirrorsreact/vitest.config.tsplusvite-plugin-relay-lite(matches BUI's existing prod build pipeline).__test__/vitest.jest-compat.ts(same pattern) +__test__/jest-globals-shim.tsthat redirectsimport { ... } from '@jest/globals'to a re-export fromvitest.jest.mock(...)→vi.mock(...)in 4 files (onlyvi.mockis hoisted by Vitest).BAIBackButton.test.tsx: convertedjest.requireActual(...)to the asyncimportOriginalfactory pattern.// TODO(FR-2609)markers.Root
/src+/scripts(4 files, 90 passing + 1 skipped)/vitest.config.ts(Node env, minimal) +/__test__/vitest.jest-compat.ts.package.json;testscript now runsvitest run.scripts/i18n-merge-driver.test.ts:jest.mock→vi.mock. The singlefs-mock test is skipped with// TODO(FR-2609)— CJSrequire("fs")inside the plain.jsdriver doesn't pick up Vitest's mock.Skip decisions (each with
TODO(FR-2609)in source)BAIButton,BAIUnmountAfterClose)supportTransitionstaystrueunder jsdom 29, waits fortransitionendthat never fires. Jest's older jsdom triggered the sync fallback.i18n-merge-driver.test.tsvi.mock('fs', ...)doesn't propagate into the CJSrequire("fs")inside the JS driver.Test plan
pnpm --prefix ./packages/backend.ai-ui run vitest→ 315 pass, 5 skippnpm exec vitest run(root) → 90 pass, 1 skipreact/(FR-2609) remains 856/856Stack
Builds on FR-2609. Followed by FR-2611 which retires the CRA/Craco build system now that all test suites are off Jest.